﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="clr-namespace:Elysium.Parameters;assembly=Elysium">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="SliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}" >
        <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}" 
                               StrokeThickness="0" 
                               Width="{TemplateBinding Width}" 
                               Height="{TemplateBinding Height}" 
                               SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="SliderRepeatButtonValuableStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource SliderRepeatButtonStyle}" >
        <Setter Property="Background" Value="{StaticResource AccentBrush}" />
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="SliderThumbStyle" TargetType="{x:Type Thumb}" >
        <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" 
                               BorderBrush="{TemplateBinding BorderBrush}" 
                               BorderThickness="{TemplateBinding BorderThickness}" 
                               Width="{TemplateBinding Width}" 
                               Height="{TemplateBinding Height}" 
                               SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
            </Trigger>
            <Trigger Property="Thumb.IsDragging" Value="True">
                <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <ControlTemplate x:Key="HorizontalSliderTemplate" TargetType="{x:Type Slider}" >
        <Grid Panel.Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TickBar Grid.Row="0" TickBar.Fill="{TemplateBinding BorderBrush}" TickBar.Placement="Top" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
            <Rectangle x:Name="PART_SelectionRange" Grid.Row="1" Fill="{StaticResource ForegroundBrush}" StrokeThickness="0" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Hidden" />
            <Track x:Name="PART_Track" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Track.DecreaseRepeatButton>
                    <RepeatButton ButtonBase.Command="{x:Static Slider.DecreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Height="{TemplateBinding params:Slider.TrackSize}" FrameworkElement.Style="{StaticResource SliderRepeatButtonValuableStyle}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.ThumbThickness}" FrameworkElement.Style="{StaticResource SliderThumbStyle}" BorderThickness="{Binding RelativeSource={RelativeSource Self},Path=(params:General.DefaultPaddingValue),Mode=OneWay,Converter={StaticResource DoubleToThicknessConverter},ConverterParameter=Right}" Height="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ActualHeight,Mode=OneWay}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton ButtonBase.Command="{x:Static Slider.IncreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Height="{TemplateBinding params:Slider.TrackSize}" FrameworkElement.Style="{StaticResource SliderRepeatButtonStyle}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <TickBar Grid.Row="2" TickBar.Fill="{TemplateBinding BorderBrush}" TickBar.Placement="Bottom" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
        </Grid>
    </ControlTemplate>
    <ControlTemplate x:Key="VerticalSliderTemplate" TargetType="{x:Type Slider}" >
        <Grid Panel.Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TickBar Grid.Column="0" TickBar.Fill="{TemplateBinding BorderBrush}" TickBar.Placement="Top" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
            <Rectangle x:Name="PART_SelectionRange" Grid.Column="1" Fill="{StaticResource ForegroundBrush}" StrokeThickness="0" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Hidden" />
            <Track x:Name="PART_Track" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Track.DecreaseRepeatButton>
                    <RepeatButton ButtonBase.Command="{x:Static Slider.DecreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.TrackSize}" FrameworkElement.Style="{StaticResource SliderRepeatButtonValuableStyle}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb IsEnabled="{TemplateBinding IsEnabled}" Height="{TemplateBinding params:Slider.ThumbThickness}" FrameworkElement.Style="{StaticResource SliderThumbStyle}" BorderThickness="{Binding RelativeSource={RelativeSource Self},Path=(params:General.DefaultPaddingValue),Mode=OneWay,Converter={StaticResource DoubleToThicknessConverter},ConverterParameter=Top}" Width="{Binding RelativeSource={RelativeSource TemplatedParent},Path=ActualWidth,Mode=OneWay}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton ButtonBase.Command="{x:Static Slider.IncreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.TrackSize}" FrameworkElement.Style="{StaticResource SliderRepeatButtonStyle}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <TickBar Grid.Column="2" TickBar.Fill="{TemplateBinding BorderBrush}" TickBar.Placement="Bottom" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
        </Grid>
    </ControlTemplate>
    <Style x:Key="{x:Type Slider}" TargetType="{x:Type Slider}" >
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.ContentFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
            </Trigger>
            <Trigger Property="Slider.Orientation" Value="Horizontal">
                <Setter Property="MinHeight" Value="14" />
                <Setter Property="Height" Value="18" />
                <Setter Property="MaxHeight" Value="22" />
                <Setter Property="Template" Value="{StaticResource HorizontalSliderTemplate}" />
            </Trigger>
            <Trigger Property="Slider.Orientation" Value="Vertical">
                <Setter Property="MinWidth" Value="14" />
                <Setter Property="Width" Value="18" />
                <Setter Property="MaxWidth" Value="22" />
                <Setter Property="Template" Value="{StaticResource VerticalSliderTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
</ResourceDictionary>